#ifndef SOUNDMANAGER_H
#define SOUNDMANAGER_H
#include <QMediaPlayer>
#include <QMediaPlaylist>
//singleton
class SoundManager
{
    //Q_OBJECT
public:
    enum SOUND_TYPE
    {
        BGM,BGSE,SOUND,
    };
    SoundManager(const SoundManager&) = delete;
    SoundManager& operator=(const SoundManager&) = delete;
    static SoundManager& Instance();
    ~SoundManager();
    void PlayBGM(QString path,bool loop = false);
    void Play(QString path);
    void PlayBGSE(QString path,bool loop = false);
    void PlayAppSound(QString path);
    void Pause(SOUND_TYPE t);
    void Stop(SOUND_TYPE t);
    void SetVolume(float volume,SOUND_TYPE t);
    float GetTotalTime(SOUND_TYPE t);
    float GetPosition(SOUND_TYPE t);
    QMediaPlayer* GetPlayer(SOUND_TYPE t);
private:
    QMediaPlaylist* bgm;
    QMediaPlaylist* bgse;//Background sound effect
    QMediaPlayer *bgmPlayer;
    QMediaPlayer *soundPlayer;
    QMediaPlayer *bgsePlayer;
    QMediaPlayer *appPlayer;//播放按键音之类的应用声音
    SoundManager();
};
#endif // SOUNDMANAGER_H
